#  Copyright (c) Huawei Technologies Co., Ltd. 2023-2023. All rights reserved.
import configparser
import os
from abc import ABC, abstractmethod

from distutils.sysconfig import get_python_lib
from vulcanus.log.log import LOGGER


class ReportGenerator(ABC):
    @staticmethod
    def get_resource_bundle():
        config = configparser.ConfigParser()
        resource_path = os.path.join(get_python_lib(), "zeus", "operation_service", "resource", 'i18n_zh_CN.properties')
        config.read(resource_path, encoding="utf-8")
        config_inspection = config['INSPECTION']
        resourceBundle = dict()
        for key in config_inspection.keys():
            resourceBundle[key] = config_inspection[key].encode('ascii').decode("unicode-escape")
        return resourceBundle

    def __init__(self, report_path):
        self._report_path = report_path

    @abstractmethod
    def generate_report(self, raw_data):
        pass


class ReportContext():
    @property
    def generator(self) -> ReportGenerator:
        return self._generator

    @generator.setter
    def generator(self, generator: ReportGenerator):
        self._generator = generator

    def generate_report(self, raw_data):
        self._generator.generate_report(raw_data)
